#!/usr/bin/php
<?php

function mystrtok($s)
{
    $w[] = strtok($s, " \n");

    while (($word = strtok(" \n")) != FALSE)
        $w[] = $word;

    return $w;
}

function main()
{
    printf("请输入字符串1: ");
    $s1 = fgets(STDIN);
    printf("请输入字符串2: ");
    $s2 = fgets(STDIN);

    // $s1 = "what is your name";
    // $s2 = "is myisname is name kyo";

    $a1 = mystrtok($s1);
    $a2 = mystrtok($s2);

    // var_dump($a1);
    // var_dump($a2);

    foreach ($a1 as $s) {
        // $key = array_search($s, $a2);
        $keys = array_keys($a2, $s);
        if (count($keys) != 0)
        {
            foreach ($keys as $k)
            {
                unset($a2[$k]);
            }
        }
        else
            $r[] = $s;
    }

    $s = implode(" ", $r)." ".implode(" ", $a2);

    echo $s, PHP_EOL;

    return 0;
}

exit(main());

